package group2assignone.ucm.manager;

import group2assignone.dao.MyDAO;
import group2assignone.model.Flight;
import group2assignone.ucm.UCController;
import group2assignone.ucm.UCStartup;
import group2assignone.view.manager.EditFlightView;
import group2assignone.view.manager.ManagerView;

/**
 * use case controller to edit a flight
 * @author group2
 */
public class UCEditFlightDone implements UCController {

    private EditFlightView editView = new EditFlightView();
    private Flight f;// = new Flight();

    /**
     * sets view and flight
     * @param eView
     * @param flight
     */
    public UCEditFlightDone(EditFlightView eView, Flight flight) {
        editView = eView;
        f = flight;

    }

    @Override
    public void run() {
        //save details

        MyDAO coms = UCStartup.getInstance().getDAO();
        editView.loadDetails(f);
        coms.sQLEditFlight(f, editView.getOldFlightNum());
        //go back to main login screen
        editView.dispose();
        ManagerView mv = ManagerView.getInstance();
        mv.setVisible(true);
    }
    ;
}
